package lc;

import java.util.HashMap;
import java.util.Map;

public class SingleNumber2 {

	public int singleNumber(int [] A) {
		HashMap<Integer, Integer> map1 = new HashMap<>();
		for (int i : A) {
			if (!map1.containsKey(i)) {
				map1.put(i, 0);
			}
			Integer count = map1.get(i);
			map1.put(i, count+1);			
		}
		
		for (Map.Entry<Integer, Integer> entry : map1.entrySet()) {
			if (entry.getValue() == 1) {
				return entry.getKey();
			}
		}
		return 0;
	}
	
}
